/**
 * @file 工单操作-改贴花
 * @author yangjiangming <449654337@qq.com>
 * @date 2018-12-10 20:13:16
 */

layui.define(['layer', 'form', 'upload','list_modify_common', '$http'], function (exports) {
    var $ = layui.$;
    var form = layui.form;
    var upload = layui.upload;
    var opCommonUtils = layui.list_modify_common;

    var $http = layui.$http;

    function bigImage() {
        layer.photos({
            photos:"#showimages",
            anim:0
        })
    }
    /**
     * 上传图片
     */
    function upLoadImages() {
        var uploadList = upload.render({
            elem: '#d-images',
            url: '',
            accept: 'images',
            acceptMime: 'image/jpg, image/png',
            multiple: true,
            before: function (obj) {
                obj.preview(function (index,file,result) {
                    $('#showimages').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img">')
                })
            },
            done: function (obj) {
            },
            error: function (obj) {
                layer.msg("")
            }
        })
    }

    /**
     * 初始化页面
     */
    function initPage() {
        //上传图片
  //      upLoadImages()
        //查看贴花大图
        bigImage();
    }

    /**
     * 初始化页面事件
     */
    function initEvent() {
        //保存
        form.on("submit()", function (data) {
            var url = '/work/modify/save/applique.action';

            $http.lockSave(url, data.field, data.elem).then(function () {
                layer.msg('操作成功', {icon: 1, time: 1000}, function () {
                    opCommonUtils.goOperateHome();
                });
            }, function (msg) {
                layer.msg(msg);
            });

            return false;
        })



    }

    // 程序入口
    function init() {

        // 初始化页面
        initPage();

        // 初始化事件
        initEvent();

    }


    // 初始化
    init();

    exports('oms_work_modify_applique');
});
